package org.example.maventest.utils;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil;
import lombok.Data;

/**
 * @author hqz
 * @version 1.0.0
 * @ClassName AuthorizationUtil
 * @Description TODO
 * @createTime 2021年12月07日 19:09:00
 */
@Data
public class AuthorizationUtil {
    public static String username = "root";
    public static String basicUrl = "https://127.0.0.1";
    public static String password;
    public static String port;

    public static String buildUrl(String url) {
        return String.format("%s:%s%s", basicUrl, port, url);
    }

    public static String getAuthorization() {
        if (StrUtil.isBlank(password)) {
            return "";
        }
        String token = String.format("%s:%s", username, password);
        return String.format("Basic %s", Base64.encode(token,"UTF-8"));
    }
}
